package com.yanqu.road.server.cmd.activity.carptrip;

import com.yanqu.road.entity.activity.carptrip.CarpTripConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.CarpTripProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.carptrip.CarpTripMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CARP_TRIP_GET_PVP_DATA, desc = "PVP 数据获得")
public class CarpTripGetPVPCellDataCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        CarpTripConfig config = CarpTripMgr.getConfig();
        if (config == null || !ActivityMgr.activityInShowTime(config.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }

        CarpTripProto.CrossGetCarpTripPVPCellDataReqMsg.Builder crossReq = CarpTripProto.CrossGetCarpTripPVPCellDataReqMsg.newBuilder();
        crossReq.setActivityId(CarpTripMgr.getActivityId());
        player.sendPacket(Protocol.C_CARP_TRIP_GET_PVP_TOP, crossReq);
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            player.sendPacket(Protocol.U_CARP_TRIP_GET_PVP_DATA, CarpTripProto.GetCarpTripPVPCellDataRspMsg.newBuilder().setRet(ret));
        }
    }
}
